/**************************************************************************************** Import */
import _ from 'lodash';
import React, {Component} from 'react';
import { TextInput, View, Dimensions, TouchableHighlight } from 'react-native';
import { Icon,  List, Button, InputItem, Tabs, TextareaItem, DatePicker, Accordion } from 'antd-mobile-rn';
import { CAround, CBetween, CCenter, CColumn, CFloat, CHand, CItemX, CItemY, CLine, CLoad, CRow, CWrap, CBone, CIcon, CImage, CSvg, CText, CFull, CScroll, CFooter, CHeader, CPage, CButton, CLabel, PTabbar, PHeader } from '../../../../library/comp';
import { Dialog, Http, PageBase } from '../../../../library/func';
import Design from '../../../../design';
import Config from '../../../../config';

/**************************************************************************************** Pageload */

/**************************************************************************************** Cacheload */

/**************************************************************************************** Preload */

/**************************************************************************************** Get */

/**************************************************************************************** Post */

/**************************************************************************************** Page */
 export default class UserSettingCar extends PageBase {
    constructor(props) {
        super(props);
        this.state = {
            // 车辆列表变量
            carList:[
                {
                    id:1,
                    set_number:"冀F115VR",
                },
                {
                    id:2,
                    set_number:"冀F116VR",
                },
                {
                    id:3,
                    set_number:"冀F117VR",
                },
                {
                    id:4,
                    set_number:"冀F118VR",
                },

            ],
        };

    }

    /************************************************************************************ Life */
    /**
     * didMount
     */
    componentDidMount(){
        // http请求
        // HttpTemp.get({
        //     url:"/CPage/mycar/list.php",
        //     success:(res) => {
        //         let data = res.data;
        //         this.setState({
        //             carList:data,
        //         })
        //     }
        // })
    }

    /************************************************************************************ Render */
    render(){
        return(
            <CPage>

                <CScroll bg='rgba(248, 248, 248, 1)' mt='96'>

                    {
                        this.state.carList.length == 0 ?

                        /* 如果车辆列表为空的话，显示一张空页图片 */
                        <CColumn style={[ this.state.carList.length != 0 ? { display:"none"} : { } ]}>
                            <CItemY x="cener" mt="100"> 
                                <CIcon width="150" height="150" color="#999" icon={ Design.icon["mycar-list"] }></CIcon>
                                <CText color="#999" size="30">
                                还没有添加车辆，
                                    <CText color="#00CC66" size="30" 
                                    onPress={
                                        (e)=>{
                                            //添加车辆的链接
                                            console.log("添加");
                                        }
                                    }>
                                    立即添加!
                                    </CText>
                                </CText>
                            </CItemY>
                        </CColumn>
                        :
                        /* 如果车辆列表不为空的话，显示我的车辆 */
                        <CColumn style={[this.state.carList.length == 0 ? { display:"none"} : { } ]}>
                        {this.state.carList.map((item,index)=>{
                            return(
                                <CItemX h="100" mt="20" bg="white" y="center" mx='20' ra='8'
                                    onPress={ (e)=> { this.nav.navigate('User_Setting_Car_Detail');} }
                                > 
                                    <CText size='34' f="1" mx='20'>{ item.set_number }</CText>
                                </CItemX>
                        )
                        })}    
                        </CColumn>
                    }

                </CScroll>

                {/* header */}
                <PHeader nav={this.nav} right=
                    {
                        <CHand
                            onopacity='0.6'
                            onPress={()=>{ 
                                this.nav.navigate('User_Setting_Car_Add');
                                // console.log("添加");
                            }}>
                            <CText size='26'>添加</CText>
                        </CHand>
                    }
                >车辆详情</PHeader>

            </CPage>
        )
    }
}

